<?php

namespace App\Http\Controllers;

use EasyWeChat\Foundation\Application;
use Illuminate\Http\Request;

class UsersController extends Controller
{
    public $wechat;

    /**
     * UsersController constructor.
     * @param Application $wechat
     */
    public function __construct(Application $wechat)
    {
        $this->wechat = $wechat;
    }

    /**
     * 获取公众号所有用户的openid
     * @return mixed
     */
    public function users()
    {
        $users = $this->wechat->lists();
        return $users;
    }

    /**
     * 获取单个用户的基本信息
     * @param $openId
     * @return \EasyWeChat\Support\Collection
     */
    public function user($openId)
    {
        $user = $this->wechat->user->get($openId);
        return $user;
    }

    /**
     * 修改备注
     * @return string
     */
    public function remark()
    {
        $this->wechat->user->remark('写上用户的openId','修改的备注');
        //接口正确则返回ok
        return 'ok';
    }
}
